package ui;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import Games.GamesModel;
import javax.swing.JOptionPane;

public class GameFrame extends JFrame {
	
    GameBoardView boardView;
    GamePlayerView playerView;
    GameScoreView scoreView;
    GameControllerView controllerView;
    GameHistoryView historyView;
    
    private GamesModel gameModel;

    public GameFrame(GamesModel gameModel) {
        this.gameModel = gameModel;
        init();
    }

    public void init()
    {
        setLayout(null);

        boardView = new GameBoardView();
        boardView.setBounds(13, 13, 400, 400);
        
        playerView = new GamePlayerView();
        playerView.setBounds(423, 5, 300, 100);

        scoreView = new GameScoreView();
        scoreView.setBounds(423, 108, 300, 100);

        controllerView = new GameControllerView(this, gameModel);
        controllerView.setBounds(423, 210, 300, 205);

        historyView = new GameHistoryView();
        historyView.setBounds(10, 423, 713, 243);

        getContentPane().add(boardView);
        getContentPane().add(playerView);
        getContentPane().add(scoreView);
        getContentPane().add(controllerView);
        getContentPane().add(historyView);

        Toolkit toolkit = this.getToolkit();
        Dimension screensize = toolkit.getScreenSize();

        setLocation((screensize.width/2) - (800/2) - 100, (screensize.height/2) - (400/2) - 160);        
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setPreferredSize(new Dimension(1000,700));
        setSize(739,700);
        setResizable(false);
        setVisible(true);
    }
    
    public GameBoardView getBoardView(){
        return boardView;
    }
    
    public GamePlayerView getPlayerView(){
        return playerView;
    }
    
    public GameScoreView getScoreView(){
        return scoreView;
    }
    
    public GameHistoryView getHistoryView(){
        return historyView;
    }

    public GamesModel getGameModel() {
            return gameModel;
    }

    public void setGameModel(GamesModel gameModel) {
            this.gameModel = gameModel;
    }
    
    public void showMessageDialog(String state,String message) {
            JOptionPane.showMessageDialog(this,message,state,
            JOptionPane.ERROR_MESSAGE);
        }
    
    /*
    public static void main(String[] args) {
        
    	Board board = new Board(3,3);
    	
    	GameFrame gf = new GameFrame();
    	
    	GamesModel gamesModel = new GamesModel(board);
    	
    	GamesController controller = new GamesController(gamesModel,gf);
    	
    	BoardCanvas canvas = new BoardCanvas(gf.getBoardView().getWidth(),gf.getBoardView().getHeight(),3,3,gamesModel, controller);
        
    	gf.getBoardView().add(canvas);
        
    }
	*/
}
